package com.dream.myqiyi.ui;


import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.view.View;
import android.widget.Toast;

import com.dream.myqiyi.Global;
import com.dream.myqiyi.R;

public class Welcome extends Activity {
	private SharedPreferences sp = null;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.welcome);
        sp = this.getSharedPreferences("userinfo", Context.MODE_PRIVATE);

//	    if (sp.getBoolean("autologin", false)) {
//	    	login(sp.getString("username", ""), sp.getString("password", ""));
//	  	}
    	login("note", "123");

    }
    
    private void login(String username, String password) {
    	if ("note".equals(username) && "123".equals(password)) {

    		Global.username = username;
    		Intent intent = new Intent();
    		intent.setClass(Welcome.this, LoadingActivity.class);
    		startActivity(intent);
    		Welcome.this.finish();
    		Toast.makeText(getApplicationContext(), "自动登录", Toast.LENGTH_SHORT).show();
    		
    	} else {
    		Toast.makeText(getApplicationContext(), "自动登录失败", Toast.LENGTH_SHORT).show();
    	}
    }

    public void welcome_login(View v) {  
      	Intent intent = new Intent();
		intent.setClass(Welcome.this,Login.class);
		startActivity(intent);
		//this.finish();
      }  
    public void welcome_register(View v) {  
      	Intent intent = new Intent();
		intent.setClass(Welcome.this,NoteListActivity.class);
		startActivity(intent);
		//this.finish();
      }  
   
}
